<?php

use yii\helpers\Html;
use common\components\ActiveForm;
use yii\helpers\Url;
use kartik\file\FileInput;

/* @var $this yii\web\View */
/* @var $model common\models\document */
/* @var $form yii\widgets\ActiveForm */
?>
<hr/>
<div class="document-form">

    <?php $form = ActiveForm::begin([
		'options' => [
			'class' => 'form-horizontal',
			'enctype' => 'multipart/form-data'
		],
		'fieldConfig' => [
			'template' => "{label}\n<div class=\"col-xs-5\">{input}</div>\n{hint}\n{error}",
		]
	]); ?>

	<ul id="myTab" class="nav nav-tabs" role="tablist" style="margin-bottom: 20px">
		<li role="presentation" class="active">
			<a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">基本</a>
		</li>
		<li role="presentation" class="">
			<a href="#profile" role="tab" id="profile-tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">扩展</a>
		</li>
	</ul>

	<div id="myTabContent" class="tab-content">
		<div role="tabpanel" class="tab-pane fade active in" id="home" aria-labelledby="home-tab">

			<?= $form->field($model, 'title')->textInput(['maxlength' => 80])->label(null, [
				'class' => 'col-sm-2 control-label'
			]) ?>

			<?= $form->field($model, 'category_id')->dropDownList(\yii\helpers\ArrayHelper::map($list, 'id', 'name'))->label(null, [
				'class' => 'col-sm-2 control-label'
			]) ?>

			<?= $form->field($model, 'description')->textarea(['maxlength' => 200, 'rows' => 6])->label(null, [
				'class' => 'col-sm-2 control-label'
			]) ?>

			<?= $form->field($model, 'image')->widget(FileInput::classname(), [
				'options' => ['accept' => 'image/*'],
			])->label(null, [
				'class' => 'col-sm-2 control-label'
			]); ?>
			<?php if($model->image): ?>
				<?= Html::activeHiddenInput($model, 'image') ?>
				<div class="col-xs-offset-2" style="margin-bottom: 5px">
					<span class="word-btn"></span>
					<?= Html::img('@web/' . $model->image, ['width' => 50, 'height' => 50]) ?>
				</div>
			<?php endif; ?>

			<?= $form->field($model, 'content', ['template' => "{label}\n<div class=\"col-xs-10\">{input}</div>\n{hint}\n{error}",])->widget(
				\cliff363825\kindeditor\KindEditorWidget::className(),[
				'clientOptions' => [
					'uploadJson' => Url::to(['upload/uploadeditor']),
					'width' => '90%',
					'height' => '350px',
					'themeType' => 'default', // optional: default, simple, qq
					'langType' => 'zh_CN', // optional: ar, en, ko, zh_CN, zh_TW
				],
			])->label(null, [
				'class' => 'col-sm-2 control-label'
			]) ?>

		</div>

		<div role="tabpanel" class="tab-pane fade" id="profile" aria-labelledby="profile-tab">

			<?= $form->field($model, 'view')->textInput(['maxlength' => 10])->label(null, [
				'class' => 'col-sm-2 control-label'
			]) ?>

		</div>
	</div>



    <div class="form-group">
		<div class="col-xs-2"></div>
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', '创建文章') : Yii::t('app', '更新文章'), ['class' => $model->isNewRecord ? 'btn btn-success word-btn' : 'btn btn-primary word-btn']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

<script>
	<?php $this->beginBlock('js_end') ?>

	$(function(){
		highlight_subnav("<?= Url::to(['article/index']) ?>");
	});

	<?php $this->endBlock() ?>
</script>

<?php $this->registerJs($this->blocks['js_end'], \yii\web\View::POS_END); ?>
